﻿<%@ Page Language="C#" MasterPageFile="~/Game/Game.Master" AutoEventWireup="true"
    CodeBehind="FleetView.aspx.cs" Inherits="smallDeimos.Game.FleetView" Title="Small Deimos - Sent Fleet" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<%--    <script language="javascript" src="../jquery-1.2.6.min.js" type="text/javascript"></script>

    <script language="javascript" src="../JSFunctions.js" type="text/javascript"></script>
--%>
    <script language="javascript" type="text/javascript">
    
function Update()
{
var sysL = document.getElementById('<%= ToSystemList.ClientID %>')
var planetL = document.getElementById ('<%= ToPlanet.ClientID %>')
var fromS = document.getElementById('<%= FromSystem.ClientID %>')
var fromP = document.getElementById('<%= FromPlanet.ClientID %>')
var EL = document.getElementById('<%= EnergyField.ClientID %>')
var SL = document.getElementById('<%= SpeedField.ClientID %>')
var energy = parseInt(EL.value)
var speed = parseInt(SL.value)
var fs = parseInt(fromS.value)
var fp = parseInt(fromP.value);
var sys = 0;
var planet = 0;
    try
    {
        sys = parseInt(sysL.value);
    }
    catch(err)
    {
        alert("Type in system box a number")
    }
    try
    {
        planet = parseInt(planetL.value)
    }
    catch(err)
    {
        alert("Type in system box a number")
    }

    $("#FlightTime").load("HandleAjaxCalls.aspx?type=ajax&operation=FlightTime&energy="+energy.toString()+"&speed="+speed.toString()+
        "&sId1="+fs.toString()+"&sId2="+sys.toString()+"&p1="+fp.toString()+"&p2="+planet.toString());
}
    </script>

    <table>
        <tr>
            <td>
                Colony ships
            </td>
            <td>
                <asp:TextBox ID="ColonyBox" runat="server" CssClass="x-TextBox">0</asp:TextBox>
            </td>
            <td>
                <asp:Label ID="ColonyLabel" runat="server" Text="Label"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                Transports
            </td>
            <td>
                <asp:TextBox ID="TransportBox" runat="server" CssClass="x-TextBox">0</asp:TextBox>
            </td>
            <td>
                <asp:Label ID="TransportLabel" runat="server" Text="Label"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                Destroyers
            </td>
            <td>
                <asp:TextBox ID="DestBox" runat="server" CssClass="x-TextBox">0</asp:TextBox>
            </td>
            <td>
                <asp:Label ID="DestLabel" runat="server" Text="Label"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                Cruisers
            </td>
            <td>
                <asp:TextBox ID="CrBox" runat="server" CssClass="x-TextBox">0</asp:TextBox>
            </td>
            <td>
                <asp:Label ID="CrLabel" runat="server" Text="Label"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                Battleships
            </td>
            <td>
                <asp:TextBox ID="BsBox" runat="server" CssClass="x-TextBox">0</asp:TextBox>
            </td>
            <td>
                <asp:Label ID="BsLabel" runat="server" Text="Label"></asp:Label>
            </td>
            <td>
                <asp:Button ID="Button2" runat="server" Text="All" OnClick="Button2_Click" />
            </td>
        </tr>
        <tr>
            <td>
                From:
            </td>
            <td colspan="2">
                <asp:Label ID="FromSys" runat="server" Text="Label"></asp:Label>
                <asp:HiddenField ID="EnergyField" runat="server" Value="0" />
                <asp:HiddenField ID="SpeedField" runat="server" Value="0" />
                <asp:HiddenField ID="FromPlanet" runat="server" Value="0" />
                <asp:HiddenField ID="FromSystem" runat="server" Value="0" />
            </td>
        </tr>
        <tr>
            <td>
                To system
            </td>
            <td colspan="2">
                <asp:DropDownList ID="ToSystemList" runat="server" DataSourceID="SqlDataSource1"
                    DataTextField="SystemName" DataValueField="SystemID">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:smallDeimosConnectionString %>"
                    SelectCommand="SELECT SystemID, SystemName FROM Systems WHERE (SQRT(POWER(X - (SELECT X FROM Systems AS Systems_2 WHERE (SystemID = (SELECT OrginID FROM Players WHERE (PlayerId = @pId)))), 2) + POWER(Y - (SELECT Y FROM Systems AS Systems_1 WHERE (SystemID = (SELECT OrginID FROM Players AS Players_2 WHERE (PlayerId = @pId)))), 2)) &lt;= (SELECT Biology FROM Players AS Players_1 WHERE (PlayerId = @pId)) / 2) AND (SystemID &lt;= (SELECT LastOrginID FROM Configuration))">
                    <SelectParameters>
                        <asp:CookieParameter CookieName="sd_id" Name="pId" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td>
                To planet
            </td>
            <td colspan="2">
                <asp:TextBox ID="ToPlanet" runat="server" CssClass="x-TextBox" onchange="Update()">1</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                Flight time
            </td>
            <td colspan="2">
                <div id="FlightTime">
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <asp:Button ID="Button1" runat="server" Text="Start" OnClick="Button1_Click" />
                <asp:Label ID="Label1" runat="server"></asp:Label>
            </td>
        </tr>
    </table>
</asp:Content>
